function createProxy(value = 0) {
  const toPrimitive = () => value
  return new Proxy({}, {
    get(target, key) {
      if (key === Symbol.toPrimitive) {
        return toPrimitive
      }
      return createProxy(value + Number(key))
    }
  })
}

const add = createProxy()

const r1 = add[1][2][3] + 4 // 期望值 10
const r2 = add[10][20] + 30 // 期望值 60
const r3 = add[100][200][300] + 400 // 期望值 1000
console.log(r1);
console.log(r2);
console.log(r3);